package com.yanqu.road.server.cmd.drugstore;

import com.yanqu.road.pb.drugstore.DrugStoreProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.drugstore.DrugStoreModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;


@Cmd(code = Protocol.S_DRUG_STORE_LAND_UNLOCK, desc = "土地解锁")
public class DrugStoreUnlockLandCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        DrugStoreProto.UnlockDrugLandReqMsg reqMsg = DrugStoreProto.UnlockDrugLandReqMsg.parseFrom(packet.getBytes());
        int landId = reqMsg.getLandId();

        ret =  player.getModule(DrugStoreModule.class).unlockLandData(landId);
    }

    @Override
    public void sendData(GamePlayer player) {
        if(ret != 0){
            player.sendPacket(Protocol.U_DRUG_STORE_LAND_UNLOCK, DrugStoreProto.UnlockDrugLandRespMsg.newBuilder().setRet(ret));
        }
    }
}
